package ExceptionDemo;

public class exceptiondemo1 {
    public static void main(String[] args) {
        //目标：搞清楚异常的作用
        System.out.println("程序开始进行。。。");
        try
        {
            System.out.println(div(10, 2));;
            System.out.println("底层方法执行成功了~~");
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.out.println("程序出现异常了~~");
        }

        System.out.println("程序结束。。。");
    }
    public static int div(int a,int b) throws Exception
    {
        if(b == 0)
        {
           throw new RuntimeException("除数不能为0");
        }
        int result = a/b;
        return result;
    }

}
